using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_Restaurant {
		#region Fields
		private int iD;
		private int restaurantId;
		private string name;
		private string description;
		private string detail;
		private string imageURL;
		private int cityID;
		private int lanuageId;
		private string overView;
		private int star;
		private int rating;
		private string address;
		private string telephone;
		private string fax;
		private string openTime;
		private int unitPrice;
		private int startHour;
		private int startMin;
		private int duration;
		private int timeStatus;
		private string locCode;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_Restaurant class.
		/// </summary>
		public TF_Restaurant() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Restaurant class.
		/// </summary>
		public TF_Restaurant(int restaurantId, string name, string description, string detail, string imageURL, int cityID, int lanuageId, string overView, int star, int rating, string address, string telephone, string fax, string openTime, int unitPrice, int startHour, int startMin, int duration, int timeStatus, string locCode) {
			this.restaurantId = restaurantId;
			this.name = name;
			this.description = description;
			this.detail = detail;
			this.imageURL = imageURL;
			this.cityID = cityID;
			this.lanuageId = lanuageId;
			this.overView = overView;
			this.star = star;
			this.rating = rating;
			this.address = address;
			this.telephone = telephone;
			this.fax = fax;
			this.openTime = openTime;
			this.unitPrice = unitPrice;
			this.startHour = startHour;
			this.startMin = startMin;
			this.duration = duration;
			this.timeStatus = timeStatus;
			this.locCode = locCode;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Restaurant class.
		/// </summary>
		public TF_Restaurant(int iD, int restaurantId, string name, string description, string detail, string imageURL, int cityID, int lanuageId, string overView, int star, int rating, string address, string telephone, string fax, string openTime, int unitPrice, int startHour, int startMin, int duration, int timeStatus, string locCode) {
			this.iD = iD;
			this.restaurantId = restaurantId;
			this.name = name;
			this.description = description;
			this.detail = detail;
			this.imageURL = imageURL;
			this.cityID = cityID;
			this.lanuageId = lanuageId;
			this.overView = overView;
			this.star = star;
			this.rating = rating;
			this.address = address;
			this.telephone = telephone;
			this.fax = fax;
			this.openTime = openTime;
			this.unitPrice = unitPrice;
			this.startHour = startHour;
			this.startMin = startMin;
			this.duration = duration;
			this.timeStatus = timeStatus;
			this.locCode = locCode;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the RestaurantId value.
		/// </summary>
		public int RestaurantId {
			get { return restaurantId; }
			set { restaurantId = value; }
		}
		
		/// <summary>
		/// Gets or sets the Name value.
		/// </summary>
		public string Name {
			get { return name; }
			set { name = value; }
		}
		
		/// <summary>
		/// Gets or sets the Description value.
		/// </summary>
		public string Description {
			get { return description; }
			set { description = value; }
		}
		
		/// <summary>
		/// Gets or sets the Detail value.
		/// </summary>
		public string Detail {
			get { return detail; }
			set { detail = value; }
		}
		
		/// <summary>
		/// Gets or sets the ImageURL value.
		/// </summary>
		public string ImageURL {
			get { return imageURL; }
			set { imageURL = value; }
		}
		
		/// <summary>
		/// Gets or sets the CityID value.
		/// </summary>
		public int CityID {
			get { return cityID; }
			set { cityID = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanuageId value.
		/// </summary>
		public int LanuageId {
			get { return lanuageId; }
			set { lanuageId = value; }
		}
		
		/// <summary>
		/// Gets or sets the OverView value.
		/// </summary>
		public string OverView {
			get { return overView; }
			set { overView = value; }
		}
		
		/// <summary>
		/// Gets or sets the Star value.
		/// </summary>
		public int Star {
			get { return star; }
			set { star = value; }
		}
		
		/// <summary>
		/// Gets or sets the Rating value.
		/// </summary>
		public int Rating {
			get { return rating; }
			set { rating = value; }
		}
		
		/// <summary>
		/// Gets or sets the Address value.
		/// </summary>
		public string Address {
			get { return address; }
			set { address = value; }
		}
		
		/// <summary>
		/// Gets or sets the Telephone value.
		/// </summary>
		public string Telephone {
			get { return telephone; }
			set { telephone = value; }
		}
		
		/// <summary>
		/// Gets or sets the Fax value.
		/// </summary>
		public string Fax {
			get { return fax; }
			set { fax = value; }
		}
		
		/// <summary>
		/// Gets or sets the OpenTime value.
		/// </summary>
		public string OpenTime {
			get { return openTime; }
			set { openTime = value; }
		}
		
		/// <summary>
		/// Gets or sets the UnitPrice value.
		/// </summary>
		public int UnitPrice {
			get { return unitPrice; }
			set { unitPrice = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartHour value.
		/// </summary>
		public int StartHour {
			get { return startHour; }
			set { startHour = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartMin value.
		/// </summary>
		public int StartMin {
			get { return startMin; }
			set { startMin = value; }
		}
		
		/// <summary>
		/// Gets or sets the Duration value.
		/// </summary>
		public int Duration {
			get { return duration; }
			set { duration = value; }
		}
		
		/// <summary>
		/// Gets or sets the TimeStatus value.
		/// </summary>
		public int TimeStatus {
			get { return timeStatus; }
			set { timeStatus = value; }
		}
		
		/// <summary>
		/// Gets or sets the LocCode value.
		/// </summary>
		public string LocCode {
			get { return locCode; }
			set { locCode = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_Restaurant table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_RestaurantInsert", restaurantId, name, description, detail, imageURL, cityID, lanuageId, overView, star, rating, address, telephone, fax, openTime, unitPrice, startHour, startMin, duration, timeStatus, locCode));
		}
		
		/// <summary>
		/// Updates a record in the TF_Restaurant table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_RestaurantUpdate", iD, restaurantId, name, description, detail, imageURL, cityID, lanuageId, overView, star, rating, address, telephone, fax, openTime, unitPrice, startHour, startMin, duration, timeStatus, locCode);
		}
		
		/// <summary>
		/// Deletes a record from the TF_Restaurant table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_RestaurantDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_Restaurant table.
		/// </summary>
		public static TF_Restaurant Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_RestaurantSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_Restaurant(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_Restaurant table.
		/// </summary>
		public static List<TF_Restaurant> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_RestaurantSelectAll")) {
				List<TF_Restaurant> tF_RestaurantList = new List<TF_Restaurant>();
				while (dataReader.Read()) {
					TF_Restaurant tF_Restaurant = MakeTF_Restaurant(dataReader);
					tF_RestaurantList.Add(tF_Restaurant);
				}
				return tF_RestaurantList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_Restaurant class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_Restaurant MakeTF_Restaurant(SqlDataReader dataReader) {
			TF_Restaurant tF_Restaurant = new TF_Restaurant();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_Restaurant.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_Restaurant.RestaurantId = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_Restaurant.Name = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_Restaurant.Description = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_Restaurant.Detail = dataReader.GetString(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_Restaurant.ImageURL = dataReader.GetString(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_Restaurant.CityID = dataReader.GetInt32(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_Restaurant.LanuageId = dataReader.GetInt32(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_Restaurant.OverView = dataReader.GetString(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_Restaurant.Star = dataReader.GetInt32(9);
			}
			if (dataReader.IsDBNull(10) == false) {
				tF_Restaurant.Rating = dataReader.GetInt32(10);
			}
			if (dataReader.IsDBNull(11) == false) {
				tF_Restaurant.Address = dataReader.GetString(11);
			}
			if (dataReader.IsDBNull(12) == false) {
				tF_Restaurant.Telephone = dataReader.GetString(12);
			}
			if (dataReader.IsDBNull(13) == false) {
				tF_Restaurant.Fax = dataReader.GetString(13);
			}
			if (dataReader.IsDBNull(14) == false) {
				tF_Restaurant.OpenTime = dataReader.GetString(14);
			}
			if (dataReader.IsDBNull(15) == false) {
				tF_Restaurant.UnitPrice = dataReader.GetInt32(15);
			}
			if (dataReader.IsDBNull(16) == false) {
				tF_Restaurant.StartHour = dataReader.GetInt32(16);
			}
			if (dataReader.IsDBNull(17) == false) {
				tF_Restaurant.StartMin = dataReader.GetInt32(17);
			}
			if (dataReader.IsDBNull(18) == false) {
				tF_Restaurant.Duration = dataReader.GetInt32(18);
			}
			if (dataReader.IsDBNull(19) == false) {
				tF_Restaurant.TimeStatus = dataReader.GetInt32(19);
			}
			if (dataReader.IsDBNull(20) == false) {
				tF_Restaurant.LocCode = dataReader.GetString(20);
			}

			return tF_Restaurant;
		}
		#endregion
	}
}
